<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>cState Admin</title>
  </head>
  <body>
    <!--
    To easily manage your status on Netlify,
    much like on WordPress, you need to keep
    this directory. Platforms which do not
    support Netlify CMS do not need this
    /admin/ directory.
    -->

    <script>console.log('You are using cState. The version can be looked at from the console on the homepage or incidents view. https://github.com/cstate')</script>

	<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
    <script>
      var IssuePreview = createClass({
        render: function() {
          var entry = this.props.entry;

          var layoutPostDate = entry.getIn(['data', 'date']);
          var layoutPostDateEnd = entry.getIn(['data', 'resolvedWhen']);

          var resultOfStateProps = {"class": "warning"};
          var resultOfState = 'This incident has not yet been resolved.';

          if (entry.getIn(['data', 'resolved']) === true) {
            var resultOfStateProps = {"class": "green"};
            var resultOfState = 'This incident has been resolved.';
          }

          if (entry.getIn(['data', 'informational']) === true) {
            var resultOfStateProps = {"class": "green"};
            var resultOfState = '';
          }


          return h('div', {},
            h('h1', {}, entry.getIn(['data', 'title'])),
            h('p', {},
              h('strong', resultOfStateProps, resultOfState)
            ),
            h('div', {"className": "text"}, this.props.widgetFor('body'))
          );
        }
      });
      CMS.registerPreviewTemplate("issues", IssuePreview, { raw: true });

      const previewStyles = `
        html,
        body {
          padding: 16px;
          color: #444;
          background: #fff;
          font: 100%/1.5 BlinkMacSystemFont, -apple-system, "San Francisco Text", "Roboto", "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
        }

        h1 {
          line-height: 1;
          margin: 0;
          color: #000;
          font-weight: normal;
          font-size: 40px;
          font-family: "Segoe UI", BlinkMacSystemFont, -apple-system, "San Francisco Text", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
        }

        small {
          margin-top: 12px;
          color: #666;
          font-variant: small-caps;
          display: block;
        }

        .text {
          padding-top: 12px;
          border-top: 1px solid #ccc;
        }

        .green { color: #228B22; }
        .red { color: #DC143C; }
        .warning { color: #EE7600; }
      `;
      CMS.registerPreviewStyle(previewStyles, { raw: true });
    </script>
  </body>
</html>
